package me.qingy.core.service.impl;

import me.qingy.core.entity.Role;
import me.qingy.core.mapper.RoleMapper;
import me.qingy.core.service.RoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * <p>
 * 角色信息表 服务实现类
 * </p>
 *
 * @author qingy
 * @since 2021-04-21
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Override
    public Set<String> selectRolePermissionByUserId(Long userId) {
        List<Role> roles = this.baseMapper.selectRolesByUserId(userId);
        return roles.stream().map(Role::getRoleKey).collect(Collectors.toSet());
    }
}
